package edu.washington.ling.syntric.consistency;

import edu.washington.ling.syntric.struct.tree.Token;
import edu.washington.ling.syntric.struct.tree.Tree;

public class ConsistencyUtils {

	public static Token createBaseEC(String ecType, String relType) {
		return createEC(ecType, relType);
	}
	public static Token createMovementEC(String ecType, String relType, int index) {
		Token ec = createEC(ecType, relType);
		ec.setDSSourceIndex(index);
		return ec;
	}
	
	public static Token createEC(String ecType, String relType) {
		Token ec = new Token();
		ec.setWord("NULL");
		ec.setTag("NULL");
		ec.setFeature("af", ",,,,,,,");
		ec.setFeature("ectype", ecType);
		ec.setFeature("mtype", "non-gap");
		ec.setDSRelation(relType);
		return ec;
	}
	
	public static void attachECs(Tree ds, OrderModule orderModule) {
		attachECs(ds.getDSRoot(), ds, orderModule);
	}
	
	private static void attachECs(Token t, Tree ds, OrderModule orderModule) {
		for (Token ecChild: t.getECDependents()) {
			orderModule.attachEmtpyCategory(ecChild, t, ds);
		}
		for (Token child: t.getDSDependents()) {
			attachECs(child, ds, orderModule);
		}
	}
}
